package com.itheima.d2_byte_stream;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * 目标：使用文件字节输入流一次读取完文件的全部字节。
 */
public class FileInputStreamTest3 {
    public static void main(String[] args) throws IOException {

      /*  FileOutputStream fos = new FileOutputStream("day09file-io-app/file/File01.txt");
        fos.write(97);*/
        //方法一
        File file = new File("day09file-io-app/file/File01.txt");
        FileInputStream fis1 = new FileInputStream(file);
        byte[] bytes1 = new byte[(int) file.length()];

        fis1.read(bytes1);
        System.out.println(new String(bytes1));

        fis1.close();
        //方法二

        FileInputStream fis = new FileInputStream("day09file-io-app/file/File01.txt");

        byte[] bytes = fis.readAllBytes();

        System.out.println(new String(bytes));

        fis.close();

    }
}
